<script setup>
import {useUserStore} from "@/stores/myStore.js";
import {onMounted} from "vue";
import {get} from "@/utils/axiosMethod.js";
import router from '@/router'

const userStore = useUserStore()
/**
 * 查看是否已经登录过了，看下后端是否有记录
 */
onMounted(()=> {
  if (userStore.auth.user === null) {
    get('/api/user/me', (userInfo)=> {
      userStore.auth.user = userInfo
      console.log(userStore.auth.user)
      router.push('/index')
    }, ()=> {
      userStore.auth.user = null
    })
  }
})
</script>

<template>
<!--  <button class="btn">btn</button>-->
  <router-view/>
</template>

<style scoped>
/*.btn {
    @apply bg-green-400 text-indigo-50 px-4 py-2 rounded-2xl transition-all hover:(bg-purple-900);
}*/
</style>
